// File Name: step_motor_task.c
// Author: kukukukuku~
// Date: 2024-07-04

#include "./User/Step_Motor/inc/step_motor_task.h"

TaskHandle_t taskHandleStepMotor;   //Step_Motor任务句柄

SemaphoreHandle_t semaphBinStepMotor;   //Step_Motor二值信号量

/**
 * @brief   Step_Motor任务
 * @param   arg:    任务参数
 * @retval  None
 * @note    None
*/
void task_step_motor(void *arg)
{
    step_motor_set_mode(stepMotorMode);
    step_motor_set_rotate_speed(stepMotorSpd);
    
    while(1)
    {
        if(xSemaphoreTake(semaphBinStepMotor, portMAX_DELAY) == pdTRUE)
        {
            switch(stepMotorState)
            {
                case STEP_MOTOR_STOP:
                    step_motor_stop();
                    break;
                case STEP_MOTOR_CW:
                    step_motor_cw();
                    break;
                case STEP_MOTOR_CCW:
                    step_motor_ccw();
                    break;
                default:
                    step_motor_stop();
                    break;
            }
        }
    }
}
